/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.agtranscontinental.dgs001.model;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author ericson
 */
@Entity
@Table(name = "cargo")
@NamedQueries({
    @NamedQuery(name = "Cargo.findAll", query = "SELECT c FROM Cargo c"),
    @NamedQuery(name = "Cargo.findByIdCg", query = "SELECT c FROM Cargo c WHERE c.idCg = :idCg"),
    @NamedQuery(name = "Cargo.findByNombCg", query = "SELECT c FROM Cargo c WHERE c.nombCg = :nombCg")})
public class Cargo implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "id_cg")
    private Integer idCg;
    @Size(max = 60)
    @Column(name = "nomb_cg")
    private String nombCg;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cargo")
    private List<Personal> personalList;

    public Cargo() {
    }

    public Cargo(Integer idCg) {
        this.idCg = idCg;
    }

    public Integer getIdCg() {
        return idCg;
    }

    public void setIdCg(Integer idCg) {
        this.idCg = idCg;
    }

    public String getNombCg() {
        return nombCg;
    }

    public void setNombCg(String nombCg) {
        this.nombCg = nombCg;
    }

    public List<Personal> getPersonalList() {
        return personalList;
    }

    public void setPersonalList(List<Personal> personalList) {
        this.personalList = personalList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCg != null ? idCg.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Cargo)) {
            return false;
        }
        Cargo other = (Cargo) object;
        if ((this.idCg == null && other.idCg != null) || (this.idCg != null && !this.idCg.equals(other.idCg))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.agtranconstinental.dgs001.model.Cargo[ idCg=" + idCg + " ]";
    }
    
}
